/// @tags:
#include <algorithm>
#include <cstdio>
#include <iostream>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

constexpr int maxn = 1024 * 1024 + 1;

int a[maxn];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  int q;
  cin >> q;
  while (q--) {
    int b;
    cin >> b;
    int index = std::lower_bound(a, a + n, b) - a;
    cout << "index: " << index << endl;
    int cnt = 0, l = 0, r = n - 1;
    while (l < r) {
      ++cnt;
      int lmid = (l + r) / 2;
      int hmid = (l + r + 1) / 2;
      if ((l + r) % 2 == 0) {
        if (lmid == index) {
          r = lmid;
        } else if (index < lmid) {
          r = lmid - 1;
        } else {
          l = lmid + 1;
        }
      } else if (lmid >= index) {
        r = lmid;
      } else {
        l = hmid;
      }
    }
    cout << cnt << '\n';
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("T2.in", "r", stdin);
  freopen("T2.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
